Python Operator
welcome to the coding world!!!!
In last chapter we have seen python data types if you haven't seen yet then click here
Types of Operator
Python language supports the following types of operators.
- Arithmetic Operators
- Comparison (Relational) Operators
- Assignment Operators
- Logical Operators
- Bit wise Operators
- Membership Operators
- Identity Operators
Assignment Operators
+ Addition Adds values on either side of the operator. a + b = 30
- Subtraction Subtracts right hand operand from left hand operand. a – b = -10
* Multiplication Multiplies values on either side of the operator a * b = 200
/ Division Divides left hand operand by right hand operand b / a = 2
% Modulus Divides left hand operand by right hand operand and returns b % a = 0
remainder
Identity Operators
Assignment Operators
These operators are used to compare two things. Also, they are used to define a relation among them. They are also called as relational operators
Bit wise Operators
These operator works on bits and they perform bit by bit operation. Assume if a = 60; and b = 13; Now in the binary format their values will be 0011 1100 and 0000 1101 respectively. Following table lists out the bit wise operators supported by Python language with an example each in those, we use the above two variables (a and b) as operands
a = 0011 1100
b = 0000 1101
-----------------
a&b = 0000 1100
a|b = 0011 1101
a^b = 0011 0001
~a = 1100 0011
Python Logical Operators
There are following logical operators supported by Python language. Assume variable a holds 10 and variable b holds 20 then
0 Comments